<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
  <title>添加/编辑文章-Sydney Admin</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="../Public/css/bootstrap.min.css" />
  <link rel="stylesheet" href="../Public/css/bootstrap-responsive.min.css" />
  <link rel="stylesheet" href="../Public/css/colorpicker.css" />
  <link rel="stylesheet" href="../Public/css/datepicker.css" />
  <link rel="stylesheet" href="../Public/css/uniform.css" />
  <link rel="stylesheet" href="../Public/css/select2.css" />
  <link rel="stylesheet" href="../Public/css/matrix-style.css" />
  <link rel="stylesheet" href="../Public/css/matrix-media.css" />
  <link rel="stylesheet" href="../Public/css/bootstrap-wysihtml5.css" />
  <link href="../Public/font-awesome/css/font-awesome.css" rel="stylesheet" />
  <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'></head>
<body>
  <!-- header -->
  <!--Header-part-->
  <div id="header">
    <h1>
      <a href="dashboard.html">Sydney Admin</a>
    </h1>
  </div>
  <!--close-Header-part-->

  <!--top-Header-menu-->
  <div id="user-nav" class="navbar navbar-inverse">
    <ul class="nav">
      <li  class="dropdown" id="profile-messages" >
        <a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"> <i class="icon icon-user"></i>
          <span class="text">此生不换</span> <b class="caret"></b>
        </a>
        <ul class="dropdown-menu">
          <li>
            <a href="#"> <i class="icon-user"></i>
              个人资料
            </a>
          </li>
         <!--  <li class="divider"></li>
          <li>
            <a href="#">
              <i class="icon-check"></i>
              My Tasks
            </a>
          </li> -->
          <li class="divider"></li>
          <li>
            <a href="<?php echo U('Index/loginOut');?>">
              <i class="icon-key"></i>
              退出
            </a>
          </li>
        </ul>
      </li>
      <!--
      <li class="dropdown" id="menu-messages">
        <a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle">
          <i class="icon icon-envelope"></i>
          <span class="text">Messages</span>
          <span class="label label-important">5</span> <b class="caret"></b>
        </a>
        <ul class="dropdown-menu">
          <li>
            <a class="sAdd" title="" href="#">
              <i class="icon-plus"></i>
              new message
            </a>
          </li>
          <li class="divider"></li>
          <li>
            <a class="sInbox" title="" href="#">
              <i class="icon-envelope"></i>
              inbox
            </a>
          </li>
          <li class="divider"></li>
          <li>
            <a class="sOutbox" title="" href="#">
              <i class="icon-arrow-up"></i>
              outbox
            </a>
          </li>
          <li class="divider"></li>
          <li>
            <a class="sTrash" title="" href="#">
              <i class="icon-trash"></i>
              trash
            </a>
          </li>
        </ul>
      </li>
    -->
      <li class="">
        <a title="" href="<?php echo U('Index/setting');?>">
          <i class="icon icon-cog"></i>
          <span class="text">系统设置</span>
        </a>
      </li>
      <li class="">
        <a title="" href="<?php echo U('Index/loginOut');?>">
          <i class="icon icon-share-alt"></i>
          <span class="text">退出</span>
        </a>
      </li>
    </ul>
  </div>
  <!--close-top-Header-menu -->
  <!-- header end -->
  
  <!-- sidebar -->
  <!--start-top-serch-->
  <div id="search">
    <form method='get' action='http://www.baidu.com/s' target='_blank'>
    <input type="text" name='wd' id='wd' placeholder="搜索..."/>
    <button type="submit" class="tip-bottom" title="Search">
      <i class="icon-search icon-white"></i>
    </button>
  </form>
  </div>
  <!--close-top-serch-->
  <!--sidebar-menu-->
  <div id="sidebar">
    <a href="javascript:;" class="visible-phone">
      <i class="icon icon-home"></i>
      Dashboard
    </a>
    <ul>
      <li>
        <a href="<?php echo U('Index/index');?>">
          <i class="icon icon-home"></i>
          <span>综合信息</span>
        </a>
      </li>
      <li class='submenu'>
        <a href='<?php echo U("Article/index");?>'>
          <i class='icon icon-cogs'></i>
          <span>文章管理</span>
        </a>
        <?php $atlist = M("ArticleType")->field("id,name,key")->order("sort desc,id asc")->select(); ?>
        <ul>
          <li>
            <a href='<?php echo U("Article/index");?>'>
              <span>所有文章</span>
            </a>
          </li>
          <?php if(is_array($atlist)): $i = 0; $__LIST__ = $atlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li>
            <a href='<?php echo U("Article/index",array("ckey"=>$vo["key"]));?>'>
              <span><?php echo ($vo["name"]); ?></span>
            </a>
          </li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
      </li>
      <li>
        <a href='<?php echo U("ArticleType/index");?>'>
          <i class='icon icon-cogs'></i>
          <span>文章类别</span>
        </a>
      </li>
      <li>
        <a href='<?php echo U("Link/index");?>'>
          <i class='icon-cogs'></i>
          <span>友情连接</span>
        </a> 
      </li>
        <li class='submenu'>
            <a href=''>
                <i class='icon-cogs'></i>
                <span>公众平台</span>
            </a>
            <ul>
                <li>
                    <a href=''>
                        <i class='icon-cog'></i>
                        <span>平台设置</span>
                    </a>
                </li>
                <li>
                    <a href=''>
                        <i class='icon-file'></i>
                        <span>消息回复</span>
                    </a>
                </li>
                <li>
                    <a href=''>
                        <i class='icon-file'></i>
                        <span>消息推送</span>
                    </a>
                </li>
            </ul>
        </li>
    </ul>
  </div>
  <!--sidebar-menu-->
  <!-- sidebar end -->

  <div id="content">
    <div id="content-header">
      <div id="breadcrumb">
        <a href="index.html" title="Go to Home" class="tip-bottom">
          <i class="icon-home"></i>
          首页
        </a>
        <a href="<?php echo U('Article/index');?>" class="tip-bottom">文章列表</a>
        <a href="__SELF__" class="current">发布文章</a>
      </div>
    </div>
    <div class="container-fluid">
      <div class="row-fluid">
        <div class="span12">
          <div class='alert' style='display:none;'>
            <a class='close' data-dismiss='alert' href='javascript:;'>×</a>
            <span id='actMsg'></span>
          </div>
          <div>
            <button class='btn' onclick='history.back();'>返回</button>
          </div>
          <div class="widget-box">
            <div class="widget-title">
              <span class="icon">
                <i class="icon-align-justify"></i>
              </span>
              <h5>发布文章</h5>
            </div>
            <div class="widget-content">

              <form class="form-horizontal" id='fm-data' method='post' action="__URL__/save" >
                <?php if(($sign) != ""): ?><input type='hidden' name='id' value='<?php echo ($sign["id"]); ?>' /><?php endif; ?>
                <div class='control-group'>
                  <label class='control-label'>文章类别</label>
                  <div class='controls'>
                    <select name='cid' class='span6'>
                      <?php $tlist = D("ArticleType")->field("id,name")->order("sort desc,id asc")->select(); echo D()->getLastSql(); ?>
                      <?php if(is_array($tlist)): $i = 0; $__LIST__ = $tlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value='<?php echo ($vo["id"]); ?>'><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                  </div>
                </div>
                <div class="control-group">
                  <label class='control-label'>文章标题</label>
                  <div class='controls'>
                    <input type="text" name='title' value='<?php echo ($sign["title"]); ?>' class="span6" placeholder='请输入文章标题...' />
                  </div>
                </div>
                <div class='control-group'>
                  <label class='control-label'>排序</label>
                  <div class='controls'>
                    <input type='text' name='sort' value='<?php echo (($sign["sort"])?($sign["sort"]):0); ?>' class='span6' placeholder='值越大越靠前...' />
                  </div>
                </div>
                <div class='control-group'>
                  <label class='control-label'>创建时间</label>
                  <div class='controls'>
                    <input type='text' name='created_at' value='<?php echo (date("Y-m-d",($sign["created_at"])?($sign["created_at"]):time())); ?>' class='span6' placeholder='时间格式:YYYY-MM-DD默认为当前时间...' />
                    <small>格式:YYYY-MM-DD</small>
                  </div>
                </div>
                <div class='control-group'>
                  <label class='control-label'>是否显示</label>
                  <div class='controls'>
                    <select name='is_show' class='span6'>
                      <option value="1">显示</option>
                      <option value="0" <?php if(($sign["is_show"]) == "0"): ?>selected='selected'<?php endif; ?> >不显示</option>
                    </select>
                  </div>
                </div>
                <div class='control-group'>
                  <label class='control-label'>文章内容</label>
                  <div class='controls'>
                    <textarea name='content' id='ueditor' class='span6'><?php echo ($sign["content"]); ?></textarea>
                  </div>
                </div>
                <div class="form-actions">
                  <button type="submit" class="btn btn-success">确定</button>
                  <button type="reset" class="btn">重置</button>
                </div>
              </form>

            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- footer -->
  <!--Footer-part-->
<div class="row-fluid">
	<div id="footer" class="span12">
		2013 &copy; Sydney Admin. blogs
		<a href="http://www.cnblogs.com/hxtgirq710">冰糖-雪梨</a>
	</div>
</div>
<!--end-Footer-part-->
  <!-- footer end -->
  <script src="../Public/js/jquery.min.js"></script>
  <script src="../Public/js/jquery.ui.custom.js"></script>
  <script src="../Public/js/bootstrap.min.js"></script>
  <script src="../Public/js/masked.js"></script>
  <script src="../Public/js/jquery.uniform.js"></script>
  <script src="../Public/js/select2.min.js"></script>
  <script src="../Public/js/matrix.js"></script>
  <script src="../Public/js/jquery.peity.min.js"></script>
  <script src="../Public/js/ueditor/ueditor.config.js"></script>
  <script src="../Public/js/ueditor/ueditor.all.js"></script>
  <script type='text/javascript'>
  $(function(){
    <?php
 $refer = $_SERVER['HTTP_REFERER']; $refer = str_replace('http://'.$_SERVER['HTTP_HOST'],'',$refer); ?>
    var editor = new UE.ui.Editor();
    editor.render("ueditor");
    $("#sidebar li").removeClass('active');
    $("#sidebar li:has('a[href='<?php echo ($refer); ?>']')").addClass('active').addClass('open');
    $('select').select2();
    $("#fm-data").submit(function(){
      $.post($(this).attr('action'),$(this).serialize(),function(json){
        $('#actMsg').html(json.info);
        $('html,body').animate({scrollTop:0},71);
        $('.alert').addClass(json.status==0 ? 'alert-error' : 'alert-success').show().delay(710).fadeOut(function(){
          if(json.status==1){
            window.location.href='<?php echo $_SERVER["HTTP_REFERER"];?>';
          }
        });
      },'json');
      return false;
    });
  });
  </script>
</body>
</html>